<style>
	@import "../../../static/z39pc/css/app.6689eaa302.css";
	@import "../../../static/z39pc/css/app.bb9deb9e54.css";
	@import "../../../static/z39pc/css/animate.min.css";
	@import "../../../static/z39pc/css/mycss/taskDetail.css";
	@import "../../../static/z39pc/css/mycss/task.css";
</style>
<template>
	<div class="task-main-container">
	<div id="mainBody" class="chrome webkit win modal-open" style="overflow-x: hidden;">
		<div id="nTalk_post_hiddenElement" style="left: -10px; top: -10px; visibility: hidden; display: none; width: 1px; height: 1px;"></div>

		<header id="navigator">

			<div class="container-fluid navbar nav-container">
				<div class="row">
					<div class="brand">
						<a href="https://www.rishiqing.com/app/todo" style="cursor: pointer;">
							<img class="logo" src="../../../static/z39pc/assets/images/logo.png" height="32">
						</a>
					</div>
					<div class="col-sm-9">
						<ul class="nav nav-pills">
							<li class="nav-item active trigger-inside-modal-close" data-type="todo">
								<a class="nav-link type-body2-black">任务</a>
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="doc">
								<router-link to="note" tag="a" class="nav-link type-body2-black">总结</router-link>
								<!--<a href="note.html" class="nav-link type-body2-black">总结</a>-->
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="company">
								<router-link to="market" tag="a" class="nav-link type-body2-black">市场</router-link>
								<!--<a href="market.html" class="nav-link type-body2-black">市场</a>-->
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="todo">
								<router-link to="task" tag="a" class="nav-link type-body2-black">档案库</router-link>
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="todo">
								<router-link to="task" tag="a" class="nav-link type-body2-black">大冒险</router-link>
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="todo">
								<router-link to="task" tag="a" class="nav-link type-body2-black">教程</router-link>
							</li>
							<!--<li class="nav-item  trigger-inside-modal-close" data-type="todo">
								<router-link to="task" tag="a" class="nav-link type-body2-black">学习</router-link>
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="todo">
								<router-link to="task" tag="a" class="nav-link type-body2-black">价格</router-link>
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="todo">
								<router-link to="task" tag="a" class="nav-link type-body2-black">开放接口</router-link>
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="todo">
								<router-link to="task" tag="a" class="nav-link type-body2-black">公司</router-link>
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="todo">
								<router-link to="task" tag="a" class="nav-link type-body2-black">产品功能</router-link>
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="todo">
								<router-link to="task" tag="a" class="nav-link type-body2-black">合作</router-link>
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="todo">
								<router-link to="task" tag="a" class="nav-link type-body2-black">群组</router-link>
							</li>
							<li class="nav-item  trigger-inside-modal-close" data-type="todo">
								<router-link to="task" tag="a" class="nav-link type-body2-black">经典</router-link>
							</li>-->
						</ul>
					</div>
					<div class="nav-right">
						<img class="vip vip-btn tooltipstered" src="../../../static/z39pc/assets/images/personalCrowdfunding.a5b2f974a9.png" alt="vip" data-toggle="tooltip">
						<span class="btn hidden hack-pay"></span>
						<span class="btn pay-page-btn hidden"></span>
						<span class="alertRingBtn" style="display: none"></span>
						<div class="user-profile type-body2-black dropdown">
							<div class="dropdown-toggle" data-toggle="dropdown">
								<img class="avatar" src="../../../static/z39pc/assets/images/avatar.png" alt="">
								<span class="name">姜禄建</span>
							</div>
							<ul class="userSettings dropdown-menu dropdown-menu-right">
								<li>
									<a href="javascript:;" class="dropdown-item personalSettingBtn">个人设置</a>
								</li>
								<li class="dropdown-item version" data-auto-close="false">版本 v6.15.74</li>
								<li class="dropdown-divider"></li>
								<li>
									<a href="https://www.rishiqing.com/task/logout/index" data-bypass="" class="dropdown-item">退出</a>
								</li>
							</ul>
						</div>
						<ul class="menu-list">
							<li class="showNotifications popover-toggle"><i class="icon-notifications"></i><span class="unRead-mesage-num" style="display: none;"></span></li>
						</ul>
					</div>
				</div>
			</div>
		</header>
		<div id="mainContent" style="background: none;">
			<!--<template>-->
			<div class="kanban-view">
				<div class="container-left-content active">
					<div class="show-box">
						<div class="icon-right el-icon-d-arrow-right">

						</div>
					</div>
					<div class="storageBox animated RSQ_fadeInLeft" id="storageBox">
						<header style="line-height: 64px;font-size: 14px;">
							<!--<template>
								<el-tabs v-model="boxTab" type="card">
									<el-tab-pane label="任务箱" name="box"></el-tab-pane>
									<el-tab-pane label="任务清单" name="taskList"></el-tab-pane>
								</el-tabs>
							</template>-->
							任务箱（总数：{{nonesList.length}}）
							<div class="inboxDropDown dropDown" style="border:0">
								<i class="dropdown-toggle el-icon-d-arrow-left hide-box" data-toggle="dropdown" aria-expanded="false"></i>
							</div>

						</header>
						<div id="left-box-container1" v-show="boxTab=='box'">
							<div id="buttonDiv">
								<div id="storageAddInputLi" style="display: block;"  @keyup.ctrl.enter="addTask">
									<!--<input id="storageAddInput" class="type-caption-white" v-model="addTaskTitle" placeholder="任务标题"></input>-->
									
									<textarea id="storageAddTextarea" name="" rows="3" cols="" v-model="addTaskTitle" v-bind:placeholder="addTaskTitlePlaceholder"></textarea>
								</div>
								<el-button type="primary" :loading="addBtnLoading" @click="addTask">添加</el-button>
							</div>
							<div id="storageUlDiv">
								<ul class="ui-sortable unsort">
									<draggable class="dragArea" :list="nonesList" :options="{group:'task'}" @remove="dragRemove" :move="dragMove" @add="dragAddNones">

										<template v-for="item in nonesList">
											<li class="kanban-Item-container task-11 animated tooltipstered" :taskId="item.id">

												<div class="left">
													<div class="checkboxContainer"><span class="diyCheckbox" style="cursor: pointer;"><i class="icon-check_box_outline_blank blank"></i><i class="icon-check check"></i><div class="checkTail"></div></span></div>
												</div>
												<div class="right">
													<div class="portrait-container">
														<!--<img class="portrait" src="../images/avatar.png" draggable="false">
														<div class="time">07-11</div>-->
													</div>
													<div class="row1"><span v-bind:title="item.id+'.'+item.title" class="kanban-item-title">{{item.id+'.'+item.title}}</span>
														<!--<div class="receive-btn" style="display: none;">领取</div>-->
													</div>
													<div class="dateNode node"></div>
												</div>
											</li>
										</template>

									</draggable>
								</ul>
							</div>
						</div>
						<div id="left-box-container2" v-show="boxTab=='Tasklist'">
							<ul class="ui-sortable unsort" style="height: 100%;">
							</ul>
						</div>
						<!--<div class="total-account">
							总数：{{nonesList.length}}
						</div>-->
					</div>

				</div>
				<div class="container-right">
					<div class="container-right-top-bg"></div>
					<div class="container-right-bottom-bg"></div>
					<div class="container-right-content">
						<div class="weatherAndSwitchView animated RSQ_fadeInRight">
							<div class="switch3Ul blue" style="left: 2rem;">
								<ul class="task-tab" id='listTypeTab'>
									<li class="task-tab-item active">
										<router-link to="todayTask" tag="div">日</router-link>
									</li>
									<li class="task-tab-item">
										<router-link to="weekTask" tag="div">周</router-link>
									</li>
									<li class="task-tab-item">
										<router-link to="monthTask" tag="div">月</router-link>
									</li>
									<li class="task-tab-item">
										<router-link to="yearTask" tag="div">年</router-link>
									</li>
									<li class="task-tab-item">
										<router-link to="projectTask" tag="div">项目</router-link>
									</li>
								</ul>
							</div>
							<!--<div class="row" id='hl-switch'>
								<el-switch v-model="memberActive" on-color="#13ce66" on-text="" off-text="" @change="memberActiveChange()">
								</el-switch>
							</div>-->
							
							<div class="type_filter switch3Ul">
								<ul class="inUl prolist projectList">
									<li class="item" :class="projectId==''?'active':''" @click="projectCli('')">
										无
									</li>
									<template v-for="(item,index) in projects">
										<li class='item' :class="projectId==item.id?'active':''" :proId="item.id" @click="projectCli(item.id)">
											{{item.title}}
										</li>
									</template>

									<!--<li class="item active">
										项目A
									</li>-->

								</ul>
								<ul class="inUl prolist memberList" style="display: none;">
									<li class="item">
										全部
									</li>
									<template v-for="(item,index) in members">
										<li :class='["item",index==0?"active":""]' :memberId="item.id">
											{{item.name}}
										</li>
									</template>

									<!--<li class="item">
										张三
									</li>-->
								</ul>
							</div>
							<div class="project-btn-container">
								<div class="add-container" @click="showProjectDialog('add')">
									<div class="add-container-bg">
										<span></span>添加项目
									</div>
								</div>
								<div class="delete-container" @click="deleteProject()">
									<div class="delete-container-bg">
										<span></span>
									</div>
								</div>
								<div class="set-container" @click="showProjectDialog('edit')">
									<div class="set-container-bg">
										<span></span>
									</div>
								</div>
								<div class="member-switch">
									<el-switch v-model="memberActive" on-color="#13ce66" on-text="" off-text="" @change="memberActiveChange()">
									</el-switch>
								</div>
							</div>
							<div class="block" id="datePicker">
								<el-date-picker v-model="showMonth" :clearable="false" :editable="false" v-show="(taskType=='today')||(taskType=='month')" @change="monthChange()" type="month" placeholder="选择月">
								</el-date-picker>
								<el-date-picker v-model="showWeek" :clearable="false" :editable="false" v-show="taskType=='week'" type="week" @change="weekChange" placeholder="选择周" format="yyyy 第 WW 周" :picker-options="pickerOptions2">
								</el-date-picker>
								<el-date-picker v-model="showYear" :clearable="false" :editable="false" v-show="taskType=='year'" @change="yearChange()" type="year" placeholder="选择年">
								</el-date-picker>
							</div>
						</div>
						<div class="filter-condition">
							<ul>
								<li>所有网络</li>
								<li>进行中</li>
								<li>筛选</li>
								<li>按截止日期排序</li>
							</ul>
						</div>
							
						<!-- 写右边的内容 -->

						<router-view ref="taskChildPage" v-on:transformCircle="circleTransform" class="view" keep-alive transition transition-mode="out-in">
						</router-view>
						<project-dialog ref="projectDialog"></project-dialog>
					</div>
				</div>
			</div>
		</div>
		<!--</template>-->
	</div>

	</div>
</div>
</template>
<div id="cli_dialog_div"></div>
<div id="cli_dialog_div"></div>
<div id="cli_dialog_div"></div>
<script>
	import '../../../static/z39pc/js/jquery-2.1.0.js'
	import draggable from 'vuedraggable'
	import _ from "underscore";
	import moment from "moment";
	import projectDialog from '../../components/task/projectDialog.vue'
	import api from '../../api';
	import { taskAndTag } from "../../common/mixin";
	import { mixinPc } from "../../common/mixinPc";
	import {
		mapState,
		mapActions
	} from 'vuex'
	var initPage = function(me) {
		$('body').css({
			'height':'100%',
			'overflow':'hidden'
		})
		$('#menu-show').click(function() {
			$(this).hide();
			$('.projectList').show();
			$('.memberList').hide();
			$('.type_filter.switch3Ul').css({
				'left': '300px'
			});
		})

//		$('.inUl.prolist').on('click', 'li', function() {
//			$(this).addClass('active').siblings().removeClass('active')
//		})
		//缩小收纳箱
		//快捷键关闭任务详情
		var showAddHideBox = function(action) {
			if(action == 'hide') {
				$('#mainContent .container-left-content').animate({
					width: '50px',
				}, 300, function() {
					$('.container-left-content .show-box').show();
				})
				$('#mainContent .container-right').animate({
					left: '50px',
				}, 300)
				$('.container-left-content').removeClass('active')
			} else if(action == 'show') {
				$('#mainContent .container-left-content').animate({
					width: '311px',
				}, 300, function() {
					$('.container-left-content .show-box').hide();
				})
				$('#mainContent .container-right').animate({
					left: '311px',
				}, 300)
				$('.container-left-content').addClass('active')
			}
		}
		$(window).on('keyup', function(e) {
			e.preventDefault()
			if(e.keyCode == 27) {//esc
				var index = $('#xx li.active').index()
				$('.task-detail-container').animate({
					right: '-400px'
				}, 300)
				if(me.$route.name == '今日任务') {
					$('.kanban-main-warp .kanban-main-container').animate({
						right: '45px'
					}, 300)
				} else {
					$('.kanban-main-warp .kanban-main-container').animate({
						right: '-24px'
					}, 300)
				}
				if(me.$route.name == '单任务') {
					history.back();
				}
			} else if(e.keyCode == 16) {//shift
				if($('.container-left-content').hasClass('active')) {
					showAddHideBox('hide')
				} else {
					showAddHideBox('show')
				}
			}
		})
		$('.container-left-content').on('click', '.storageBox .hide-box', function() {
			showAddHideBox('hide')
		})
		$('.container-left-content').on('click', '.show-box', function() {
			showAddHideBox('show')
		})
		//显示隐藏任务详情
		$('body').on('dblclick', '.kanban-item-warp ul.allow-detail-click li', function(e) {
			$('.task-detail-container').show()
			$('.task-detail-container').animate({
				right: '-24px'
			}, 300)
			$('.kanban-main-warp .kanban-main-container').animate({
				right: '340px'
			}, 300)
			e.cancelBublle=true;
			e.stopPropagation();
			$(this).addClass('active');
			$(this).siblings().removeClass('active');
			itemAni(this);
		})
		$('body').on('click', '.task-detail-container .close', function() {
			$('.task-detail-container').animate({
				right: '-400px'
			}, 300)
			$('.kanban-main-warp .kanban-main-container').animate({
				right: '70px'
			}, 300)
		})

		$('body').on('dragstart', '.dragArea li.kanban-Item-container', function(e) {
			if(me.$route.name == '项目任务' && !me.projectId) {
				return false;
			}
			$('.dragArea').css('border-color', '#000')
		})
		$('body').on('drop', '.dragArea', function(e) {
			$('.dragArea').css('border-color', 'transparent')
		})

		//点击任务的时候,动画效果
		$('body').on('click', '#tagTmpList li.kanban-Item-container .right', function(e) {
			e.cancelBublle=true;
			e.stopPropagation();
			var clickParant = $($(this).parents('.kanban-Item-container')[0]);
			$(clickParant).toggleClass('active');
			$(clickParant).siblings().removeClass('active');
			itemAni(clickParant);
//			$('.kanban-card-container').find('li.kanban-Item-container').removeClass('triangle-badge-rt');
//			$(clickParant).parent().children().each(function() {
//				if($(this).attr('data-quickNo') < 10) {
//					$(this).addClass('triangle-badge-rt');
//				}
//			})
//			$('.kanban-card-container').find('.header').removeClass('active')
//			$(clickParant).parents('.kanban-card-container').find('.header').addClass('active');

		})
		$('body').on('click', '.body-tr-container .kanban-item-warp', function() {
			if(!$(this).parents('.kanban-card-container').find('.header').hasClass('not-active')){
				$(this).parents('.kanban-card-container').find('.header').click();
//				$('.kanban-card-container').find('.header').removeClass('active')
//				$(this).parents('.kanban-card-container').find('.header').addClass('active');
			}
			

		})
		
		//点击任务头
		$('body').on('click', '.kanban-card-container .header', function() {
			if(!$(this).hasClass('not-active')) {
				$('li.kanban-card-container .header').removeClass('active');
				$(this).addClass('active');

				$('.kanban-card-container').find('li.kanban-Item-container').removeClass('triangle-badge-rt');
				$(this).parents('.kanban-card-container').find('li.kanban-Item-container').each(function() {
					if($(this).attr('data-quickNo') < 10) {
						$(this).addClass('triangle-badge-rt');
					}
				})
			}
		})

		function itemAni(item) {
			$(item).removeClass("animated bounceIn");
			setTimeout(function() {
				$(item).addClass("animated bounceIn");
			}, 10);
		}

		//列表头部添加任务
		$('body').on('click', '.head-tr .addItem', function() {
			if($(this).hasClass('is-show-dialog')) {
				return;
			}
			if($(this).hasClass('icon-close')) {
				$(this).prev().hide();
				$(this).removeClass('icon-close').addClass('icon-add_circle');
			} else {
				$('.kanban-card-container .head-tr .card-rename').hide();
				$('.kanban-card-container .head-tr .addItem').removeClass('icon-close').addClass('icon-add_circle');
				$(this).prev().show();
				$(this).addClass('icon-close').removeClass('icon-add_circle');
			}
		})
		$('body').on('click', '.kanban-card-container .no-task-container', function() {
			$(this).parent().parent().siblings('.head-tr').find('.addItem').click();
		})

	}

	export default {
		data() {
			return {
				boxTab: 'box',
				dateMonth: new Date(),
				memberActive: false,
				boxList: [],
				projectList: [],
				memberList: [],
				todayList: [],
				todayTags: [],
				taskType: 'today',
				fullscreenLoading: true,
				addTaskTitle: '',
				addTaskTitlePlaceholder:'任务标题\n任务描述(回车换行后的内容自动添加到描述)快速添加快捷键Ctrl+Enter',
				addBtnLoading: false,
				dragItemData: '',
				showMonth: '',
				showYear: '',
				showWeek: new Date(),
				pickerOptions2: {
					firstDayOfWeek: 1
				},
				format: function(value, name) {
					return `${value[0]}:${value[1]}`
				},
				showTimeNeed: false,
				showPopupPicker: false,
				showSummary: false,
				taskCurr: {
					title: ""
				},
				taskDoing: null,
				sortStr: "",
				todayArr: [],
				todaySort: [],
				todaySortArr: [],
				visibility: false,
				daySelect: "",
				stateAdd: false,
				taskTitle: "",
				taskDesc: "",
				nonesList: [], //收纳箱列表,
				projectId: '', //选中的项目
			};
		},
		components: {
			draggable,
			'project-dialog': projectDialog,
		},
		mixins: [taskAndTag, mixinPc],
		computed: {
			nones: function() {

				var _this = this;
				var list = this.taskAll.filter(function(task) {
					return task.uid == _this.uid && task.state == '' && task.parid == null && task.pid == null && !(task.tags && task.tags["due"])
				});
				this.nonesList = Object.assign([], list);

			},
			getShowMonth: function() {
				return this.$store.state.z39.showMonth;
			},
			getShowYear: function() {
				return this.$store.state.z39.showYear;
			},
			...mapState({
				uid: state => state.vux.uid,
				minDate: state => state.z39.minDate,
				maxDate: state => state.z39.maxDate,
				taskAll: state => state.z39.taskAll,
				tagDic: state => state.z39.tagDic,
				taskDic: state => state.z39.taskDic,
				tagitems: state => state.z39.tagitems,
				tagitemDic: state => state.z39.tagitemDic,
				days: state => state.z39.days,
				projects: state => state.z39.projects,
				members: state => state.z39.members
			})
		},
		watch: {
			"taskAll": {
				handler() {
					this.nones;
				},
				deep: true,
			},
			"$route": function(to, from) {
				this.circleTransform(to.name)
				if(this.$route.path == '/' || this.$route.path == '/m_index') {
					console.log("index page in!");

				} else if(this.$route.name == '项目任务') {
					if(this.projects.length > 0 && !this.projectId) {
						$('.projectList li').removeClass('active');
						$('.projectList li:nth-child(2)').addClass('active');
						this.projectCli(this.projects[0].id)
					} else {
						this.projectCli(this.projectId)
					}

				}
				//路由发生变化时，更新标签模板的顺序，否则会出问题,放在today下面会监听不到
				this.$store.commit({
					type: "z39/tagTmpResort"
				});
			},
			"uid": function() {

			},
			"tagitems": function() {
				var temp = [];
				var len = this.tagitems.length;
				for(var i = 0; i <= len - 1; i++) {
					var item = this.tagitems[i];
					temp.push({
						key: item.key,
						name: item.name
					});
				}
				this.flagAllArr = temp;
				// this.$nextTick(() => {
				//   this.$refs.scrollerEvent.reset({top: 0})
				// })
			},
			"showAddTag": function() {
				let temp = [],
					tempArr = [];
				if(!this.showAddTag) { //关闭窗口
					var len = this.flagUse.length;
					for(var i = 0; i <= len - 1; i++) {
						var item = this.flagUse[i];
						temp.push(item.key);
					}
					let news = _.difference(temp, this.tagsOld);
					let dels = _.difference(this.tagsOld, temp);
					this.tagsAdd(news, false, this.taskCurr);
					this.tagsDel(dels, false, this.taskCurr);
				} else { //打开窗口,保存临时值,做后期比对.
					var tags = this.taskCurr.tags;
					for(var key in tags) {
						temp.push({
							key: key,
							name: this.tagitemDic[key]
						});
						tempArr.push(key);
					}
					this.flagUse = temp;
					this.tagsOld = tempArr;
				}
			},
			"daysDic": function() {
				this.days = this.daysDic[this.showMonth] || [];
			},
			'getShowMonth': function() {
				this.showMonth = this.$store.state.z39.showMonth;
				this.showYear = this.$store.state.z39.showYear;
			},
			'getShowYear': function() {
				this.showMonth = this.$store.state.z39.showMonth;
				this.showYear = this.$store.state.z39.showYear;
			},
		},
		created() {
			this.nones;
			this.showMonth = this.$store.state.z39.showMonth;
			this.showYear = this.$store.state.z39.showYear;
			if(this.$route.name == '单任务') { //this.$route.name=='项目任务'||
				this.$router.go(-1)
			}
			//},2000)
			//		let val = this.showMonth || moment().format("YYYY-MM");
			//		this.showMonth = val;
			//		this.$store.commit({
			//			type: "z39/showMonth",
			//			value: val
			//		});
			this.daySelect = moment().format("YYYY-MM-DD");

		},
		filters: {
			dayMin: function(month) {
				return month.replace("-", "")
			},
			dayOnly: function(day) {
				var dayMon = moment(day);
				var value = dayMon.day();
				var todayStr = moment().format("YYYY-MM-DD");
				var dayDic = {
					1: "一",
					2: "二",
					3: "三",
					4: "四",
					5: "五",
					6: "六",
					0: "日"
				};
				var show = "";
				if(day == todayStr) {
					show = "今";
				} else {
					show = (value == 0 || value == 6) ? dayDic[value] : dayMon.date();
				}
				return show;
			}
		},
		mounted: function() {
			this.circleTransform(this.$route.name)
			var _this = this;
			//			api.login({
			//				username: 'aa',
			//				password: '111111'
			//			}).then(data => {
			this.daysGet({
				type: 1,
				month: this.showMonth
			});
			//data = data.data;
			this.tagitemsGet();
			initPage(_this);
			this.usertask(this.uid);
			//}) 
		},
		methods: {
			circleTransform: function(name) {
				if(name == '单任务') {
					return;
				}
				var index = 0;
				//$('.kanban-main-container.content').css('right','0px')
				if(name == '今日任务') {
					index = 0;
					this.taskType = 'today';
					//$('.kanban-main-container.content').css('right','70px')
				} else if(name == '周任务') {
					index = 1;
					this.taskType = 'week';
				} else if(name == '月任务') {
					index = 2;
					this.taskType = 'month';
				} else if(name == '年任务') {
					index = 3;
					this.taskType = 'year';
				} else if(name == '项目任务') {
					index = 4;
					this.taskType = 'project';
				}
				//				else if(name == '单任务') {
				//					index = 5;
				//					this.taskType = 'one';
				//				}
				$('#listTypeTab li:eq(' + index + ')').addClass('active').siblings().removeClass('active');
				$('.activeCircle.center').css({
					left: index * 40 + 'px'
				})
			},
			//收纳箱添加任务
			addTask: function() {
				if(!this.addTaskTitle.split('\n')[0]) {
					this.$message({
						message: '请输入任务标题',
						type: 'warning'
					});
					return;
				}
				this.addBtnLoading = true;
				var params = {
					uid: 1,
					title: this.addTaskTitle.split('\n')[0],
					desc:this.addTaskTitle.split('\n')[1]||''
				}
				this.taskAdd(params).then(data => { 
					this.addTaskTitle=''
					this.addBtnLoading = false;
				},data => { 
					this.addBtnLoading = false;
				});
			},
			dragAddNones: function(event) {
				var routeName = this.$route.name;
				var taskId = $(event.clone).attr("taskId");
				var taskItem = this.taskDic[taskId];
				var tagId1 = this.tagDic[taskId + '_due'] ? this.tagDic[taskId + '_due'].id : '';
				if(tagId1) {
					this.tagDel({
						id: tagId1,
						key: 'due'
					}, true, taskItem);
				}
				if(routeName == '项目任务') {
					var tagId2 = this.tagDic[taskId + '_' + $(event.from).attr('tagKey')].id;
					this.tagDel({
						id: tagId2,
						key: $(event.from).attr('tagKey')
					}, true, taskItem);
					this.taskSet({
						pid: '',
						id: taskItem.id,
						state: ''
					}, taskItem); //添加pid
				}

			},
			dragRemove: function(event) {

				//				return false;
			},
			dragMove: function(event) {
				var routeName = this.$route.name;
				if(routeName == '项目任务' && !this.projectId) {
					return false;
				}
				//			this.dragItemData = event.relatedContext.element;
				//			console.log(this.nones.length)
			},
			sortdataAdd(sdata) {
				let _this = this;
				api.sortdayAdd(sdata).then(data => {
					if(data && data.errno == 0 && data.data > 0) {
						data = data.data;

						//console.log(data);
					} else { //发生错误.
						_this.$message({
							message: data.errmsg,
							type: 'error'
						});
					}
				})
			},
			daysGet(sdata) {
				let _this = this;
				api.days(sdata).then(data => {
					if(data && data.errno == 0) {
						data = data.data;
						_this.$store.commit({
							type: "z39/daysDic",
							days: data,
							month: _this.showMonth
						});
					} else { //发生错误.
						_this.$message({
							message: data.errmsg,
							type: 'error'
						});
					}
				})
			},
			onEdit(item, index) {
				this.taskCurr = item;

				let type = this.editType;
				//console.log("need", this.showTimeNeed, _.clone(item).tags.due, _.clone(item));
				switch(type) {
					case 0:
						this.showEditBtn = true;
						this.asBtnCurr = planBtnArr;
						break;
					case 1:
						let taskneed = item.tags["need"];
						this.timeNeed = (taskneed && taskneed.indexOf(":") > -1) ? taskneed.split(":") : this.timeNeed;
						this.showTimeNeed = true;
						break;
					case 2:
						this.showEditBtn = true;
						let arr = [];
						arr.push(taskBtnItem);
						if(item.state == "" || item.state == "due" || item.state == "need") {
							arr.push(startBtnItem);
						} else if(item.state == "started") {
							arr.push(toggleBtnItem);
						} else if(item.state == "toggle") {
							arr.push(restartBtnItem);
						}
						if(item.state == "done") {
							arr.push(noneBtnItem);
						} else {
							arr.push(doneBtnItem);
						}

						this.asBtnCurr = arr;
						break;
					case 3:
						this.resetSummary();
						this.showSummary = true;
						break;
					case 4:
						//在tabitemclick 中.
						this.showAddTag = true;
						break;
					default: //从添加状态点击任务,直接进入查看模式.

						console.error("index:", index);
						break;
				}
			},
			changeTime() {
				this.visibility = true;
			},
			monthChange() {
				var monthVal = moment(this.showMonth).format("YYYY-MM");
				this.$store.commit({
					type: "z39/changeDate",
					value: monthVal,
					dateType: 'month'
				});
				//			var day=this.$store.state.z39.selectedDayDate.split('-')[2];
				//			this.$store.commit({ type: "z39/changeDayDate", day:day });
				this.daysGet({
					type: 1,
					month: monthVal
				});
			},
			weekChange(val) {
				var weekVal = val;
				this.$store.commit({
					type: "z39/changeDate",
					value: weekVal,
					dateType: 'week'
				});
			},
			yearChange() {
				var yearVal = moment(this.showYear).format('YYYY');
				this.$store.commit({
					type: "z39/changeDate",
					value: yearVal,
					dateType: 'year'
				});
			},
			onDay(day) {
				this.daySelect = day;
				this.sortdayGet(day).then(data=>{
					this.sortStr = data.sorts ;
				});
			},
			clickAdd() {
				this.stateAdd = true;
				this.resetInput();
			},
			resetInput() {
				this.addTaskTitle = "";
				this.taskTitle = "";
				this.taskDesc = "";
			},
			saveSort() {
				var ids = [];
				var len = this.todayArr.length;
				for(var i = 0; i <= len - 1; i++) {
					var item = this.todayArr[i];
					ids.push(item.id);
				}
				this.sortdataAdd({
					day: this.daySelect,
					sorts: ids.join(",")
				});
			},
			projectCli: function(pid) {
				this.projectId = pid;

//				if(pid) {
					var _this = this;
					var routeName = this.$route.name;
					this.$router.push({
						path: '/projectTask'
					})
					if(routeName == '项目任务') {
						var proTime1 = setTimeout(function() {
							clearTimeout(proTime1)
							_this.$refs.taskChildPage.getTagTmpDev(pid, _this.memberActive)
						}, 1000)
					} else {
						var proTime1 = setTimeout(function() {
							clearTimeout(proTime1)
							_this.$refs.taskChildPage.getTagTmpDev(pid, _this.memberActive)
						}, 1000)
					}

//				}
			},
			memberActiveChange: function() {
				var routeName = this.$route.name;
				if(this.projectId && routeName == '项目任务') {
					this.$refs.taskChildPage.getTagTmpDev(this.projectId, this.memberActive)
				}
			},
			showProjectDialog:function(type){
				if(type=='edit'){
					this.$refs.projectDialog.editDialog(this.projectId);
				}else if(type=='add'){
					this.$refs.projectDialog.showDialog({});
				}
				
			},
			deleteProject:function(){
				var _this=this;
				if(!this.projectId){
					this.$message({
						message: '请先选择项目',
						type: 'warning'
					});
				}else{
					this.$confirm('是否确认删除当前项目?', '提示', {
			          confirmButtonText: '确定',
			          cancelButtonText: '取消',
			          type: 'warning'
			       }).then(() => {
			          _this.projectDel( _this.projectId);
			          _this.projectCli('')
//			          _this.$refs.taskChildPage.getList('', _this.memberActive)
			        }).catch(() => {
			              
			        });
				}
			},
			showTestData(item){
//				console.log(_.clone(item));
			}
		}
	}
</script>